#!/bin/bash -ex

CMAKE_SCRIPT_DIR="$(realpath $(dirname ${0}))"
SCRIPT_DIR="$(dirname ${CMAKE_SCRIPT_DIR})"
ROOT_REPO_DIR="$(dirname ${SCRIPT_DIR})"

BUILD_DIR="${ROOT_REPO_DIR}/build_ohos_arm64"
mkdir -p "${BUILD_DIR}"

cd "${BUILD_DIR}"

rm -rf *

OHOS_NAITIVE_SDK_PATH="/opt/ohos-sdk/native"

cmake \
"${ROOT_REPO_DIR}/CMakeLists.txt" \
-GNinja \
-B "${BUILD_DIR}" \
-DCMAKE_TOOLCHAIN_FILE="${ROOT_REPO_DIR}/cmake_toolchains/cross-ohos-musl-aarch64.cmake" \
-DTOOLCHAIN_SYSROOT="${OHOS_NAITIVE_SDK_PATH}/sysroot" \
-DTOOLCHAIN_CLANG_ROOT="${OHOS_NAITIVE_SDK_PATH}/llvm"
